// https://www.luogu.com.cn/problem/P1731
// 倒着搜
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
int rad(); // read int
const int max_size = 5 + 100;
const int maxn = 5 + 20;

/*
v = pi * r * r * h
s` = pi * 2 * r * h
v / s = r / 2
s = 2 * v / r
*/
int n, m; // 层数， 体积
int r[maxn], h[maxn];
int mins[maxn], minv[maxn];
int ans = inf;

void dfs(int dep = n, int pv = 0, int ps = 0) { // dep, pre v, pre s
    if (dep < 1) {
        if (pv == m) ans = min(ans, ps);
        return;
    }
    if (pv + minv[dep] > m) return;
    if (ps + mins[dep] >= ans) return;
    if (ps + 2 * (m - pv) / r[dep + 1] >= ans) return;
    for (int i = r[dep + 1] - 1; i >= dep; --i) {
        if (dep == n) ps = i * i;
        for (int j = min(h[dep + 1] - 1, (m - pv) / i / i); j >= dep; --j) {
            r[dep] = i, h[dep] = j;
            dfs(dep - 1, pv + i * i * j, ps + 2 * i * j);
        }
    }
}

int main() {
    m = rad(), n = rad();
    r[n + 1] = m + 1, h[n + 1] = m + 1;
    // min: 1 ~ n
    // max: m - n + 1 ~ m
    for (int i = 1; i <= n; ++i) {
        mins[i] = mins[i - 1] + 2 * i * i;
        minv[i] = minv[i - 1] + i * i * i;
    }
    dfs(n);
    printf("%d", ans);
}

int rad() {
    int back = 0, ch = 0, neg = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        neg = ch == '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return (back ^ -neg) + neg;
}